package com.tledu.springboot03.controller;

import com.tledu.springboot03.model.User;
import org.springframework.http.HttpRequest;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
import java.util.Date;

/**
 * @author Antg
 * @date 2021/8/25  11:50
 */
@Controller
public class UserController {
    @GetMapping("/test")
    public String test(Model model, HttpSession session){
        String name = "张三";
        String richText = "<h1>这是一段富文本</h1>";
        Date date = new Date();
        User user = new User(1,"张三","123","jack",date);
        model.addAttribute("name",name);
        model.addAttribute("richText",richText);
        model.addAttribute("user",user);
        session.setAttribute("session","这是session中的值");
        return "test";
    }
}
